// this agent waits for the group creation and then
// adopts the role loader and
// commits to the mission garbage

{ include("common.asl") }
{ include("check_obl.asl") }

/* Initial goals */
myId(3).
!start.
!join.

/* Plans called from Moise */

+!grabPownder : garbage(X) & myId(MyId)<- 
	incMyNumberCoallition(MyId);
	lookupArtifact(myGrid,_);
	goToGarbage(MyId,X);
	removeGarbage(X);
	.print("Collecting pounder...").

+!takeIncinerator: myId(MyId) <-  
					  goToIncinerator(MyId);
					  putIncinerator(1);
	                 .print("Taking to the incinerator...").
	                 
+!passProduct : garbage(X) & myId(MyId) <- 
								incMyNumberCoallition(MyId);
								goToGarbage(MyId,X);
							    sweepGarbage(X); 
								.print("Passing product..").

/* Plans for Cartago */

+?myGrid(gridId): true
  <- lookupArtifact("myGrid",_).

-?myGrid(gridId): true
  <- .wait(10);
     ?myGrid(gridId).

/* Other plans */

+!start
   <- 
      //Artefato para limpar o pó
   	  lookupArtifact("mypaper",GrId); 
      adoptRole(loader)[artifact_id(GrId)];
      //Papel para cuidar da tinta
      adoptRole(productpasser)[artifact_id(GrId)];      
      focus(GrId).     
-!start
   <- .wait(100);
      !start.
      
+!restart <- 
      !start.
      
// conditions to leave missions

@lgss1[atomic]
+goalState(Scheme,wsecs,_,_,satisfied)
    : .my_name(Me) & commitment(Me,mColaborator,Scheme)
   <- !quit_mission(mColaborator,Scheme).
      
@lgss2[atomic]
+goalState(Scheme,wrefs,_,_,satisfied)
    : .my_name(Me) & commitment(Me,mBib,Scheme)
   <- print("Quiting mission");
   	 !quit_mission(mBib,Scheme).              